/* create by neo.bai */

import { high } from 'nc-lightapp-front';

const { Refer } = high;
const { PopRefer } = Refer;
class Tree extends PopRefer {
	constructor(props) {
		super(props);
		console.log(props);
	}
	// 重写load数据方法loadTableData && loadTreeData
	// 请求列表数据
	loadTableData = async (param, useCache = true) => {
		const { queryGridUrl, pageSize, refType } = this.props;
		let { activeKey } = this.state;
		if (refType === 'gridTree' && !param.pid) {
			param.filterPids = await this.loadTreeData(
				this.__getParam({
					pageInfo: {
						pageIndex: -1,
						pageSize
					}
				})
			).then((data) => {
				return data.rows.map((e) => e.refpk);
			});
		}
		if (refType === 'gridTree' && activeKey === '1') {
			param.queryCondition.isShowUsual = true;
			param.queryCondition.UsualActionURL = queryGridUrl;
		}
		if (param.queryCondition.hasOwnProperty('isIncludeCancelDept')) {
			delete param.queryCondition.isIncludeCancelDept;
		}
		return this.sendAjax(queryGridUrl, param, useCache);
	};

	// 请求树数据
	loadTreeData = async (param, useCache = true) => {
		const { queryTreeUrl } = this.props;
		let _param_ = { ...param };
		delete _param_.queryCondition.GridRefActionExt;
		return this.sendAjax(queryTreeUrl, _param_, useCache);
	};
}
export default Tree;
